package com.shuai.jit.controller;


import com.shuai.jit.entity.R;
import com.shuai.jit.service.impl.FriendServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/user")
public class FriendController {

    @Autowired
    FriendServiceImpl friendService;

    /**
     * 获取可以添加的好友信息
     * @param userId
     * @return
     */
    @RequestMapping("addAllFriend")
    public R addAllFriend(String userId){
        return R.ok().data("friend",friendService.addAllFriend(userId)) ;
    }

    /**
     * 获取好友列表信息
     * @param userId
     * @return
     */
    @RequestMapping("getFriend")
    public R getFriend(String userId){
       return R.ok().data("friend",friendService.getFriend(userId)) ;
    }


    /**
     * 添加好友关系
     * @param userId 添加好友
     * @param friendId
     * @return
     */
    @RequestMapping("addFriend")
    public R addFriend(String userId,String friendId){
       return R.ok().data("friend",friendService.addFriend(userId,friendId));
    }

    /**
     * 接受好友请求信息
     * @param userId 接受请求的用户
     * @param friendId
     * @return
     */
    @RequestMapping("acceptFriend")
    public R acceptFriend(String userId,String friendId){
        return R.ok().data("friend",friendService.addFriend(userId,friendId));
    }

    @RequestMapping("deleteFriend")
    public R deleteFriend(String userId,String friendId){
        return R.ok().data("friend",friendService.addFriend(userId,friendId));
    }
}
